package com.example.aop.aspect;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class ReturnValueAspect {
    // 处理无返回值的方法
    @AfterReturning(pointcut = "execution(* com.example.aop.OrderService.add(..)) || " +
                              "execution(* com.example.aop.OrderService.delete(..))",
                   returning = "result")
    public void logVoidReturnValue(Object result) {
        System.out.println("方法返回值：void（无返回值）");
    }
    
    // 处理有返回值的find方法
    @AfterReturning(pointcut = "execution(* com.example.aop.OrderService.find(..))",
                   returning = "result")
    public void logIntReturnValue(Object result) {
        System.out.println("方法返回值：" + result);
    }
}
